<?php
	
	include 'database.php';

	$sql = "SELECT * FROM pizza_besteld ORDER BY date DESC";
	$result = mysqli_query($dbcon, $sql);
	
	if(isset($_SESSION['members'])){
		if($_SESSION['members']['niveau_id'] >= 4){
	
			echo "<table>";
			echo "<tr> <th>Pizza</th> <th>Klant</th> <th>Besteldatum</th> <th>Gemaakt</th> <th>Bezorgd</th><th>Delete</th>";			
			
			while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
				
				echo "<tr><td>";
				echo $row['pizza_id'];
				echo "</td><td>";
				echo $row['klant_id'];
				echo "</td><td>";
				echo $row['date'];
				echo "</td><td>";
				echo $row['gemaakt'];
				echo "</td><td>";
				echo $row['bezorgd'];
				echo "</td><td>";
				echo "<form action='delete_bestel.php' method='post'> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='".$row['Id']."' />";
				echo "</td></tr>";
			}
			echo "</table>";
			
			echo "<input id='delete' type='submit' class='button' name='delete' value='Update'/></form>";
			echo "</div>";	
		}	
	}		
	
	if(isset($_SESSION['members'])){
		if($_SESSION['members']['niveau_id'] >= 3){
	
			echo "<table>";
			echo "<tr> <th>Pizza</th> <th>Klant</th> <th>Besteldatum</th> <th>Gemaakt</th> <th>Bezorgd</th><th>Delete</th>";			
			
			while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
				
				echo "<tr><td>";
				echo $row['pizza_id'];
				echo "</td><td>";
				echo $row['klant_id'];
				echo "</td><td>";
				echo $row['date'];
				echo "</td><td>";
				echo $row['gemaakt'];
				echo "</td><td>";
				echo $row['bezorgd'];
				echo "</td><td>";
				echo "<form action='delete_bestel.php' method='post'> <input type='checkbox' name='checkbox[]' id='checkbox[]' value='".$row['Id']."' />";
				echo "</td></tr>";
			}
			echo "</table>";
			
			echo "<input id='delete' type='submit' class='button' name='delete' value='Update'/></form>";
			echo "</div>";	
		}	
	}	
	
	if(isset($_SESSION['members'])){
		if($_SESSION['members']['niveau_id'] >= 2){
	
			echo "<table>";
			echo "<tr> <th>Pizza</th> <th>Klant</th> <th>Besteldatum</th> <th>Gemaakt</th> <th>Bezorgd</th>";			
			
			while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
				
				echo "<tr><td>";
				echo $row['pizza_id'];
				echo "</td><td>";
				echo $row['klant_id'];
				echo "</td><td>";
				echo $row['date'];
				echo "</td><td>";
				echo $row['gemaakt'];
				echo "</td><td>";
				echo $row['bezorgd'];
				echo "</td><td>";
				
			}
			echo "</table>";
			
		
		}	
	}	

?>